#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from fuc import *

user = got_user()
print("==> 当前用户", user['usr'])
t=sys.argv[3]

driver = user_login(user)
print("==> 登陆结果")
cookie = cookie_check(driver)
print(cookie)

nowTime = got_now_time()
isAfter18h = now_is_after_18h(nowTime)
print("==> 当前时间", nowTime, color(isAfter18h, "18点后", "18点前"))

tmp = got_my_template(driver)

if isAfter18h:
    print("==> 开始加班签退")
    do_signout(driver, tmp['signout'])

if isAfter18h:
    print("==> 开始填加班日志 t=" + t)
    do_signlog(driver, tmp['signlog'], u"20点", t, u"开发")

if isAfter18h:
    print("==> 查结果")
    his = got_his_array(driver)
    isSignin = is_signin(his)
    isSignout = is_signout(his)
    isSignlog = is_signlog(his)
    print(color(isSignin, "今日已签到", "今日未签到"), color(isSignout, "今日已签退", "今日未签退"), color(isSignlog, "今日已填日志", "今日未填日志"))

user_logout(driver)
print("==> 已登出")

driver.quit()
